Skip to content

add weather app#206

Open
JosePadolina wants to merge 1 commit intoprojectshft:masterfrom
JosePadolina:master
Open

add weather app#206
JosePadolina wants to merge 1 commit intoprojectshft:masterfrom
JosePadolina:master

Conversation

@JosePadolina
Copy link

No description provided.

})
}

function fetchForecast() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check your code indentation. Its confusing and the scope is getting lost

<img src="http://openweathermap.org/img/wn/${weather[0].icon}.png">
`;
weatherInfo.html(currentWeatherHtml);
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error call back. What happens if it fails?

const forecastUrl = `${baseUrl}/forecast?q=${city}&appid=${apiKey}&units=imperial`;
fetch(forecastUrl)
.then(response => response.json())
.then(data => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also missing error handling

Comment on lines +24 to +31
const { name, main, weather } = data;
const currentWeatherHtml = `
<h2>Current Weather in ${name}</h2>
<p>Temperature: ${main.temp}°F</p>
<p>Conditions: ${weather[0].description}</p>
<img src="http://openweathermap.org/img/wn/${weather[0].icon}.png">
`;
weatherInfo.html(currentWeatherHtml);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separating responsibilities and creating functions can help with readability.
This is not really fetching the weather, this is already rendering something... (hint for function name)

fetch(forecastUrl)
.then(response => response.json())
.then(data => {
const forecast = data.list.filter(item => item.dt_txt.includes('12:00:00'));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine, but ideally you could have averaged the data according to the current time you are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants